from langdev_helper.llm.qwen import llm, llm0
from langdev_helper.prompt.word import get_word_prompt, get_word_list
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder

system_prompt = get_word_prompt(3)
user_prompt = "显示<单词表>中的单词"

# system_prompt = '你是一个AI助手你叫小美'
user_prompt = "你好,你是谁,叫什么名字"
user_prompt = "你有什么技能"
user_prompt = "开始讲解单词"
user_prompt = "显示一个<单词表>中的单词,\n单词表：\n"

user_prompt+= get_word_list(3)

print(system_prompt)
print(user_prompt)

messages = [
    SystemMessage(content=system_prompt),
    HumanMessage(content=user_prompt)
]

# res = llm.invoke(messages)
# print(res.content)


prompt = ChatPromptTemplate.from_messages(
    [
        ("system", system_prompt),
        MessagesPlaceholder(variable_name="messages"),
    ]
)
generate = prompt | llm0

request = HumanMessage(
    content=user_prompt
)
for chunk in generate.stream({"messages": [request]}):
    print(chunk.content, end="")
